package com.str.PQ;
import java.io.*;

public class HuffmanTest {
    
  public static void main(String args[]) throws IOException {
    BufferedReader stdin = new BufferedReader(
                           new InputStreamReader(System.in));
  	
    System.out.println("Input text:");  	
  	String text = stdin.readLine();
     	   	
    System.out.println("\nBuild the tree...");  
    Huffman.buildTree(text);
    
    System.out.println("\nOutput the tree...");
    Huffman.outputTree();
    
    System.out.println("\nPrint code table:");    
    Huffman.printCodeTable();
     
    System.out.println("\nEncode:");    
    String code = Huffman.encode(text);
    System.out.println(code);
    
    System.out.println("\nOriginal text:");
    System.out.println(text);         
    
    System.out.println("\nDecode:");
    System.out.println(Huffman.decode(code));         
  }
}